<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class MemberController extends Controller
{
    public function test1()
    {
//        $bool= DB::insert('insert into student(name, id) values(?, ?)',['test1',1]);
//        var_dump($bool);
//        $student = DB::select('select * from student');
//        var_dump($student);
        $num = DB::update('update student set name=? where id=?',['test2',1]);
        var_dump($num);
    }
    public function query1()
    {
        DB::table('student')->insert([
           ['name' => 'test5', 'id' => 5],
           ['name' => 'test6', 'id' => 6],
        ]);
    }

    public function query2()
    {
        DB::table('student')
            ->where('id',1)
            ->update(['name' => 'name']);
    }
    public function query_chunk()
    {
        echo '<pre>';
        DB::table('student')
            ->orderBy('id','desc')
            ->chunk(2,function($students){
            var_dump($students);
        });
    }
}
